package com.xjw {
	import flash.display.DisplayObject;
	import flash.display.InteractiveObject;
	import flash.display.Stage;

	/**
	 * 焦点管理
	 * @author pethan
	 *
	 */
	public class FcousManage {
		private static var _instance:FcousManage;
		private var _stage:Stage;

		public function set stage(value:Stage):void {
			_stage = value;
		}

		public static function getInstance():FcousManage {
			if (_instance == null){
				_instance = new FcousManage(new SingleStance());
			}
			return _instance;
		}

		public function FcousManage(se:SingleStance){
			if (se == null){
				throw new Error('请使用单例');
			}
		}

		/**
		 * 设置焦点
		 * @param value 可交互对象
		 *
		 */
		public function set foucs(value:InteractiveObject):void {
			this.checkStage();
			this._stage.focus = value;
		}

		//检测是否有Stage
		private function checkStage():void {
			if (this._stage == null){
				throw new Error('请先设置Stage');
			}
		}

		/**
		 * 移除焦点
		 *
		 */
		public function removeFocus():void {
			this.checkStage();
			this._stage.focus = null;
		}
	}
}

class SingleStance {
}